package com.hdoit.apollo.logical.shop.dao.impl;

import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;

import com.tennetcn.data.dao.base.ISqlExpression;
import com.tennetcn.data.dao.base.impl.SuperDao;
import com.tennetcn.data.utils.SqlExpressionFactory;
import com.hdoit.apollo.logical.shop.dao.IStaffDao;
import com.hdoit.apollo.logical.shop.model.Staff;
/**
 * @author      tancongzhu
 * @email       
 * @createtime  2018年04月24日 10:58:58
 * @comment
 */
@Component
public class StaffDaoImpl extends SuperDao<Staff> implements IStaffDao{

	@Override
	public boolean checkMobile(String mobile, String id) {

		ISqlExpression sqlExpression=SqlExpressionFactory.createExpression();
		sqlExpression.addBody("select count(id) from", Staff.class)
					.andWhere("mobile=#{mobile}")
					.setParam("mobile", mobile);
		
		if (!StringUtils.isEmpty(id)) {
			sqlExpression.andWhere("id!=#{id}")
						.setParam("id", id);
		}

		return queryCount(sqlExpression) > 0;
	}

}